import { message } from 'ant-design-vue'
import { defineStore } from 'pinia'

export const useUserStore = defineStore({
  id: 'user',
  state: () => {
    return {
      token: '',
      userInfo: {},
      config: null
    }
  },
  persist: {
    storage: localStorage,
    paths: ['token', 'userInfo', 'config']
  }
})

export const isLogin = () => {
  const userStore = useUserStore()
  return userStore.token.length > 0
}

export const openLoginTip = () => {
  message.error('您还未登录，请先登录')
}
